/**
 * \class CSpaceService
 * \brief This is a service to provide a transparent view of distributed spaces to users.
 * \version 0.3.2
 *
 * \author Woo-Hyun Kim (woorung@nhncorp.com, woorung@gmail.com)
 * \author http://blog.naver.com/wisereign .
 *
 * \date 2007/10/8
 */
#ifndef CSpaceServiceH
#define CSpaceServiceH
//-----------------------------------------------------------------
#include <iostream>
#include <map>

#include "common_space.h"
#include "service/CService.h"
#include "space/CMessage.h"
#include "space/CKeyValue.h"

using namespace std;
//-----------------------------------------------------------------
class CSpaceService : public CService
{
private:
        CSpace *cube_space;

protected:
	int parameterize(CObjectArray *objs, map<string,string> &params);
	int incarnate(CObjectArray *&pobjs, vector< CKeyValue * > &bulk_kv);

	int write(map<string,string> &params, CObjectArray *objs, int start, CObjectArray *&pobjs);
	int read(map<string,string> &params, CObjectArray *objs, int start, CObjectArray *&pobjs, bool wait);
	int take(map<string,string> &params, CObjectArray *objs, int start, CObjectArray *&pobjs, bool wait);
	int size(map<string,string> &params, CObjectArray *objs, int start, CObjectArray *&pobjs);

public:
        CSpaceService(char *name);
        CSpaceService(const CSpaceService &rhs);
        ~CSpaceService(); 

        CSpaceService *clone() const; 
	CSpaceService *newInstance() const;
        CSpaceService &operator=(const CSpaceService &rhs);

        void run(cube__CObject *in, struct cube__invokeResponse &res);
};
//-----------------------------------------------------------------
#endif
